Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Printing Extensions and Drivers /
Chapter 3 - Printer Drivers / The QuickDraw GX ImageWriter II Printer Driver Messages


Setting Up the Parameters for Printing

QuickDraw GX sends the GXSetupImageData message so that you can initialize any constant data that your driver needs to use for imaging a document. The ImageWriter II driver overrides this message with the SD_SetupImageData function, which sets up the following data for a print job:

The GXSetupImageData message is described on page 4-92 in the chapter "Printing Messages." A portion of the SD_SetupImageData function is shown in Listing 3-11. The complete version of this function is found in the QuickDraw GX sample code.

Listing 3-11 Setting up the constant data for the print job

OSErr SD_SetupImageData( gxRasterImageDataHdl hImageData )
{

   OSErr                anErr;
   gxRasterImageDataPtr pImageData;
   Boolean              isJobNotFinalQuality, isTextJobFormatMode;
   long                 imagewriterOptions;
   
   /* do the default setup */
   anErr = Forward_GXSetupImageData(hImageData);
   nrequire(anErr, Forward_GXSetupImageData);
   
   /* test for 'final' quality mode */
   isJobNotFinalQuality = !JobIsBest(&imagewriterOptions);
   
   /* test for gxTextJobFormatMode */
   isTextJobFormatMode = ( GXGetJobFormatMode( GXGetJob() ) ==
                                             gxTextJobFormatMode);
         
   /* 
      If the job is not final quality and is not using text mode,
      downgrade the imaging data to lower quality.
   */
   if (isJobNotFinalQuality  ||  isTextJobFormatMode)
      {
      /* rough or text mode */
      pImageData = *hImageData;  /* dereference for size+speed */
            
      /* image at 80 or 72 dpi */
      if (imagewriterOptions & kSuperRes)
         pImageData->hImageRes = ff(80);
      else
         pImageData->hImageRes = ff(72);
      pImageData->vImageRes = ff(72);

      /*
         If using text mode, load the draft table;
         otherwise, set up the halftone data.
      */
      if (isTextJobFormatMode)
         {  /* load the draft table */
         Handle         draftTable;
         SpecGlobalsHdl hGlobals =
                               GetMessageHandlerInstanceContext();

         anErr = Send_GXFetchTaggedDriverData('idft',
                           gxPrintingDriverBaseID, &draftTable);
         nrequire(anErr, FailedToLoadDraftTable);
         
         (**hGlobals).draftTable = draftTable;
         }
      else
         {  
         /*
            Use dither level that looks better at 72 dpi
            than do the default values from the resources.
         */
         pImageData->theSetup.planeSetup[0].planeHalftone.method
                                                               = 4;
         /* turn off color matching when in non-final mode */
         pImageData->theSetup.planeSetup[0].planeProfile = nil;
         }
...
The remainder of the SD_SetupImageData function operates similarly, modifying the default values for varying resolution values.

The JobIsBest function that is called by SD_SetupImageData accesses the job collection to establish the print quality. The code for this function is shown in
Listing 3-12. The quality information is stored as an item in the job collection that specifies how the user wants the job printed. This information is accessed from the job collection using the gxQualityTag tag ID.

Listing 3-12 Establishing the print quality

Boolean JobIsBest(long *imagewriterOptions)
{
   Boolean        isFinal;
   gxQualityInfo  jobQualitySettings;
   long           itemSize = sizeof(jobQualitySettings);
   OSErr          status;
   Collection     jobCollection;
   
   /* cache the collection */
   jobCollection = GXGetJobCollection(GXGetJob());

   isFinal = false;
   status = GetCollectionItem(jobCollection, gxQualityTag,
                  gxPrintingTagID, &itemSize, &jobQualitySettings);
   
   if ( (status == noErr) && (jobQualitySettings.currentQuality
                        == (jobQualitySettings.qualityCount-1)) )
      isFinal = true;

   /* default is kSuperRes */
   *imagewriterOptions = kSuperRes;
   itemSize = sizeof(imagewriterOptions);
   status = GetCollectionItem(jobCollection, DriverCreator, 0,
                              &itemSize, imagewriterOptions);

   return(isFinal);
   
}
The JobIsBest function returns true if the current print job is printed in final quality; otherwise, it returns false. It also accesses and returns the ImageWriter II options from the job collection.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help